Skip to content

vm: preserve global function declaration restrictions - #65061

Open
subotac wants to merge 1 commit into
nodejs:mainfrom
subotac:fix/vm-global-lexical-declaration
Open

vm: preserve global function declaration restrictions#65061
subotac wants to merge 1 commit into
nodejs:mainfrom
subotac:fix/vm-global-lexical-declaration

Conversation

@subotac

@subotac subotac commented Aug 5, 2026

Copy link
Copy Markdown

Global function declarations in a context can be reflected as configurable sandbox properties while V8 tracks their global bindings as non-configurable.

When the property query interceptor finds the sandbox property first, preserve the DontDelete attribute from the global proxy. This ensures that a subsequent lexical declaration is rejected with a SyntaxError.

Extend the existing restricted-global-property test to cover a function declaration followed by a conflicting lexical declaration.

Fixes: #65025

Keep the global proxy's DontDelete attribute when the sandbox also
contains the property, so lexical redeclarations are rejected.

Signed-off-by: subotac <73706465+subotac@users.noreply.github.com>
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem. labels Aug 5, 2026

@legendecas legendecas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that a new workaround path in the interceptor is going to help improving the vm context, given all the issue we've been encounter around the interceptors.

@subotac

subotac commented Aug 7, 2026

Copy link
Copy Markdown
Author

I used the interceptor because that's where the contextified global declaration check is currently observable. If another workaround there is the wrong direction, is there a vm-context-level hook you'd prefer?

@legendecas

Copy link
Copy Markdown
Member

I think the fix should be in V8: #65025 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. vm Issues and PRs related to the vm subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vm: lexical declaration no longer throws SyntaxError over a global function declaration in vm context (regression in v26.6.0)

3 participants